// pages/market/market.js
var app = getApp();
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    integral:8,
    navIndex:0,
    nav: [
      {
        id: "0",
        text: "全部",
      },
      {
        id: "0",
        text: "全部",
      },
      {
        id: "0",
        text: "全部",
      },
      {
        id: "0",
        text: "全部",
      },
      {
        id: "0",
        text: "全部",
      },
      {
        id: "0",
        text: "全部",
      },
    ],
    list:[
      {
        id:'9',
        img:'http://www.meiliancheng.cn/public/meiliancheng/imagezy/banner.png',
        title:'商品标题商品标题商品标题',
        tips:'商品描述 商品描述',
        price:'44',
        integral:'220',
      },{
        id: '9',
        img: 'http://www.meiliancheng.cn/public/meiliancheng/imagezy/banner.png',
        title: '商品标题商品标题商品标题',
        tips: '商品描述 商品描述',
        price: '0',
        integral: '220',
      },{
        id: '9',
        img: 'http://www.meiliancheng.cn/public/meiliancheng/imagezy/banner.png',
        title: '商品标题商品标题商品标题',
        tips: '商品描述 商品描述',
        price: '44',
        integral: '220',
      }
    ]
  },
  // 获取formid
  getFormId: function (e) {
    var formid = e.detail.formId;
    // console.log(formid);
    wx.request({
      url: app.siteInfo.siteroot + 'saveformid',
      method: "post",
      data: {
        uid: app.siteInfo.uid,
        formid: formid
      },
      success: function (res) {

      }
    })
  },
  tointegralDetail:function(){
    wx.navigateTo({
      url: '/pages/market/integralDetail/integralDetail',
    })
  },
  tointegralList: function () {
    wx.navigateTo({
      url: '/pages/market/integralList/integralList',
    })
  },
  navChoose:function(e){
    var index = e.currentTarget.dataset.index;
    var id = e.currentTarget.dataset.id;
    this.setData({
      navIndex:index,
    })
    var that = this;
    wx.request({
      url: app.siteInfo.scoreroot + 'index',
      method: "get",
      data: {
        uid: app.siteInfo.uid,
        pid: app.siteInfo.pid,
        com_part_id: app.siteInfo.com_part_id,
        cateid : id,
      },
      success: function (res) {
        that.setData({
          nav: res.data.nav,
          product: res.data.product,
        })
      }
    })
  },
  togoodsDetail:function(e){
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/market/goodsDetail/goodsDetail?id='+id,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that= this;
    wx.request({
      url: app.siteInfo.scoreroot+'index',
      method:"get",
      data:{
        uid: app.siteInfo.uid,
        pid: app.siteInfo.pid,
        com_part_id: app.siteInfo.com_part_id,
      },
      success:function(res){
        that.setData({
          nav: res.data.nav,
          product: res.data.product,
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})